//获取url参数
var params = param();
var dealState = function(data,award){
	if(data == 0){
		return "审核中";
	}else if(data == 1){
		return "奖励<b>"+award+"</b>元";
	}else{
		return "审核未通过";
	}
}
juicer.register('dealState', dealState);
$(function(){
	$(".main").empty();
	$.ajax({
		type: "get",
		url: ctx + "/weixin/getTrouble?openid="+params.openid,
		success: function(result) {
			$(".nav img").attr("src",result.user.headimgurl);
			var troubleList = result.list;
			if(!troubleList || troubleList.length<1){
				return;
			}
			var count=0,award=0;
			for(var i=0;i<troubleList.length;i++){
				if(troubleList[i].state == 0){
					count++;
				}
				award+=troubleList[i].award;
			}
			var tpl = $("#tpl").text();
			var html = juicer(tpl, {
					list: troubleList
			});
			$(".main").html(html);
			$(".t1").text(troubleList.length-count);
			$(".t2").text(award);
			$(".t3").text(count);
		},
		error: function(err) {
			console.error(err);
		}
	});
});
